package com.test.webfluxhtml.controller;


import com.test.webfluxhtml.common.CommonResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.codec.multipart.FilePart;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
public class ImageUploadController {


    /**
     * 图片文件上传 返回具体的图片地址 不进行数据库存储
     * @param file
     * @param roleName
     * @param token
     * @param needZoom
     * @param width
     * @param height
     * @return
     */
    @ApiOperation(value = "图片文件上传 返回具体的图片地址", notes = "根据用户输入的码进行验证state=1成功 0失败")
    @ApiImplicitParams( {@ApiImplicitParam(name = "file",value = "上传的图片文件",required = true,paramType = "form",dataType="__file" ),
            @ApiImplicitParam(name = "rolename",value = "角色名",required = false,paramType = "query",dataType="String"),
            @ApiImplicitParam(name = "token",value = "角色证书",required = false,paramType = "query",dataType="String"),
            @ApiImplicitParam(name = "needzoom",value = "是否需要缩放",required = false,paramType = "query",dataType ="int",defaultValue = "0"),
            @ApiImplicitParam(name = "width",value = "缩放宽度",required = false,paramType = "query",dataType ="int",defaultValue = "200"),
            @ApiImplicitParam(name = "height",value = "缩放高度",required = false,paramType = "query",dataType ="int",defaultValue = "200"),
    })
    @PostMapping(value = "/imageupload")
    public Mono<CommonResult<String>> uploadImage(@RequestParam(required = true,value = "file")FilePart file ,
                                                  @RequestParam(required = false,value = "rolename")String roleName,
                                                  @RequestParam(required = false,value = "token")String token,
                                                  @RequestParam(required = false,value = "needzoom",defaultValue = "0")Integer needZoom,
                                                  @RequestParam(required = false,value = "width",defaultValue = "200") Integer width,
                                                  @RequestParam(required = false,value = "height",defaultValue = "200") Integer height)
    {
       return null;

    }
}
